In [17]:
import numpy as np
from joommf.drivers.evolver import LLG, Minimiser
from joommf.mesh import Mesh
from joommf.sim import Sim
from joommf.energies.demag import Demag
from joommf.energies.zeeman import FixedZeeman
from joommf.energies.exchange import Exchange
import joommf.vectorfield

In [2]:
mesh = Mesh([120e-9, 120e-9, 10e-9], [5e-09, 5e-09, 5e-09])
A = 1.3e-11
gamma = 2.210173e5
dm = 0.01

In [3]:
relax = Sim(mesh, 8.0e5, name='relax', debug=True)
relax.add_energy(Demag())
H_Field = np.array([0.81345856316858023, 0.58162287266553481, 0.0])*8e4
relax.add_energy(FixedZeeman(H_Field))
relax.add_energy(Exchange(A=1.3e-11))
relax.set_evolver(LLG(t=5e-9,
                      m_init = [0, 0, 1],
                      Ms = 8.0e5,
                      alpha = 1.0,
                      gamma = 2.210173e5,
                      dm=0.01,
                      name=relax))
relax.run()


DEBUG: This simulation name already exists.
About to execute: '/Users/ryan/oommf/oommf/oommf.tcl boxsi relax3.mif'
Running simulation... This may take a while
Simulation complete
JOOMMF DEBUG MODE
Oommf Stderr:
b''



Oommf Stdout:
b'Start: "/Users/ryan/oommf-python/joommf/relax3.mif"\nOptions: -threads 2\nBoxsi version 1.2.0.6\nRunning on: ip-036-167.vpn.soton.ac.uk\nOS/machine: Darwin/x86_64\nUser: ryan\tPID: 5639\nNumber of threads: 2\nMesh geometry: 24 x 24 x 2 = 1 152 cells\nBoxsi run end.\n'
Loading simulation scalar output from relax3.odt

In [4]:
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot(relax.df.time, relax.df.mx)
plt.plot(relax.df.time, relax.df.my)
plt.plot(relax.df.time, relax.df.mz)


Out[4]:
[<matplotlib.lines.Line2D at 0x10e042da0>]

Here we can see that the magnetization has settled into a steady state. We can get the final output from the final magnetisation file name, and use this as the initial magnetisation for a dynamic simulation.


In [6]:
filename = relax.final_mag

In [10]:
dynamic = Sim(mesh, 8.0e5, name='dynamic', debug=True)
dynamic.add_energy(Demag())
H_Field = np.array([0.81345856316858023, 0.57346234436332832, 0.0])*8e4
dynamic.add_energy(FixedZeeman(H_Field))
dynamic.add_energy(Exchange(A=1.3e-11))
dynamic.set_evolver(LLG(t=5e-12,
                      m_init = filename,
                      Ms = 8.0e5,
                      alpha = 0.008,
                      gamma = 2.210173e5,
                      name=relax))
dynamic.run(stages=4000)


About to execute: '/Users/ryan/oommf/oommf/oommf.tcl boxsi dynamic.mif'
Running simulation... This may take a while
Simulation complete
JOOMMF DEBUG MODE
Oommf Stderr:
b''



Oommf Stdout:
b'Start: "/Users/ryan/oommf-python/joommf/dynamic.mif"\nOptions: -threads 2\nBoxsi version 1.2.0.6\nRunning on: ip-036-167.vpn.soton.ac.uk\nOS/machine: Darwin/x86_64\nUser: ryan\tPID: 5714\nNumber of threads: 2\nMesh geometry: 24 x 24 x 2 = 1 152 cells\nBoxsi run end.\n'
Loading simulation scalar output from dynamic.odt

In [15]:
plt.plot(dynamic.df.time, dynamic.df.mx)
plt.xlim([0,.8e-8])


Out[15]:
(0, 8e-09)

In [16]:
dynamic.final_mag


Out[16]:
'dynamic-Oxs_TimeDriver-Magnetization-000003999-0024520.omf'

In [21]:
field = joommf.vectorfield.VectorField(dynamic.final_mag)

In [27]:
plt.quiver(field.z_slice(0.5)[0], field.z_slice(0.5)[1])


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-27-8f10f14a56f8> in <module>()
----> 1 plt.quiver(field.z_slice(0.5)[0], field.z_slice(0.5)[1])

/Users/ryan/anaconda/envs/py35/lib/python3.5/site-packages/matplotlib/pyplot.py in quiver(*args, **kw)
   3210         ax.hold(hold)
   3211     try:
-> 3212         ret = ax.quiver(*args, **kw)
   3213     finally:
   3214         ax.hold(washold)

/Users/ryan/anaconda/envs/py35/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
   1810                     warnings.warn(msg % (label_namer, func.__name__),
   1811                                   RuntimeWarning, stacklevel=2)
-> 1812             return func(ax, *args, **kwargs)
   1813         pre_doc = inner.__doc__
   1814         if pre_doc is None:

/Users/ryan/anaconda/envs/py35/lib/python3.5/site-packages/matplotlib/axes/_axes.py in quiver(self, *args, **kw)
   4431         if not self._hold:
   4432             self.cla()
-> 4433         q = mquiver.Quiver(self, *args, **kw)
   4434 
   4435         self.add_collection(q, autolim=True)

/Users/ryan/anaconda/envs/py35/lib/python3.5/site-packages/matplotlib/quiver.py in __init__(self, ax, *args, **kw)
    458                                              **kw)
    459         self.polykw = kw
--> 460         self.set_UVC(U, V, C)
    461         self._initialized = False
    462 

/Users/ryan/anaconda/envs/py35/lib/python3.5/site-packages/matplotlib/quiver.py in set_UVC(self, U, V, C)
    536         U = ma.masked_invalid(U, copy=True).ravel()
    537         V = ma.masked_invalid(V, copy=True).ravel()
--> 538         mask = ma.mask_or(U.mask, V.mask, copy=False, shrink=True)
    539         if C is not None:
    540             C = ma.masked_invalid(C, copy=True).ravel()

/Users/ryan/anaconda/envs/py35/lib/python3.5/site-packages/numpy/ma/core.py in mask_or(m1, m2, copy, shrink)
   1685         _recursive_mask_or(m1, m2, newmask)
   1686         return newmask
-> 1687     return make_mask(umath.logical_or(m1, m2), copy=copy, shrink=shrink)
   1688 
   1689 

ValueError: operands could not be broadcast together with shapes (1152,) (1728,) 

In [ ]: